﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.Animations;
using UnityEngine.Playables;

public class AnimUnit : AnimBehaviour
{
    private AnimationClipPlayable anim;

    public AnimUnit(PlayableGraph graph, AnimationClip clip) : base(graph)
    {
        anim = AnimationClipPlayable.Create(graph, clip);
        adapterPlayable.AddInput(anim, 0, 1);

        Disable();
    }

    public override void Enable()
    {
        base.Enable();
        enable = true;
        adapterPlayable.SetTime(0);
        anim.SetTime(0);
        adapterPlayable.Play();
        anim.Play();
    }

    public override void Disable()
    {
        base.Disable();
        enable = false;
        adapterPlayable.Pause();
        anim.Pause();
    }

}

